package com.wc.alorithm_blue_bridge._动态规划.Q3423;

import java.util.*;
import java.io.*;
/**
 * @Author congege
 * @Description
 * 安全序列
 * https://www.lanqiao.cn/problems/3423/learning/?page=1&first_category_id=1
 * @Date Created in 2023/12/15-15:02
 */
public class Main {
    static int mod = (int)1e9 + 7;
    static int maxN = (int)1e6 + 7;
    // dp[i] 表示有i个空位的方案数
    static int[] dp = new int[maxN];
    static FastReader in = new FastReader();
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static void main(String[] args) {
        int n = in.nextInt();
        int k = in.nextInt();
        dp[0] = 1;
        for(int i = 1; i <=n; i++){
            if(i - k - 1 >= 0){
                dp[i] = (dp[i - 1] + dp[i - k - 1]) % mod;
            } else {
                // 当前面没有足够的空位的时候,我们记我们只能摆0 + 上我们摆1的方案数
                dp[i] = (dp[i - 1] + 1) % mod;
            }
        }
        out.println(dp[n]);
        out.flush();
    }
}

class FastReader{
    StringTokenizer st;
    BufferedReader br;

    FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    String next(){
        try {
            while(st == null || !st.hasMoreElements()){
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e){
            return "";
        }
        return st.nextToken();
    }
    int nextInt(){
        return Integer.parseInt(next());
    }

    String nextLine(){
        String s = "";
        try {
            s = br.readLine();
        } catch (Exception e){
            return s;
        }
        return s;
    }
}